package com.lagou.controller;

import com.lagou.EmailService;
import com.lagou.common.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "/email", description = "邮件服务")
@RestController
@RequestMapping("/email")
public class EmailController {

    @Reference
    private EmailService emailService;

    @ApiOperation(value = "发送验证码到邮箱，true成功，false失败", httpMethod = "POST", produces = "application/json")
    @PostMapping(value = "/{email}/{code}")
    public ResponseResult<Boolean> sendEmail(@PathVariable String email, @PathVariable String code) {
        return ResponseResult.success(emailService.sendEmail(email, code));
    }
}
